<style>

    .default,.blue{
        box-shadow: none;
        border: 1px solid;
        text-decoration: none;
        color: #fff;
        display: inline-block;
        padding: 6px 12px;
        margin-bottom: 0;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.42857143;
        text-align: center;
        white-space: nowrap;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
    }
    .blue{
        background: #3c8dbc;
        color: #fff;
    }
</style>








<div class="x-body">
    <form class="layui-form form_single" id="form" action="{:url()}" method="post">
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>标题
            </label>
            <div class="layui-input-block">
                <input type="text" id="username" name="name" required="" lay-verify="required"
                       autocomplete="off"  value="{$info['name']|default=''}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                (帖子标题名称)
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                排序
            </label>
            <div class="layui-input-block">
                <input type="number" id="L_pass" name="sort"
                       autocomplete="off" class="layui-input"  value="{$info['sort']|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                (排序越大，顺序越前,默认0)
            </div>
        </div>


        <div class="layui-form-item">
            <label for="pid" class="layui-form-label">
                <span class="x-red">*</span>分类
            </label>
            <div class="layui-input-block">
                <select id="pid" name="cate_id">
                    {volist name='article_category_list' id='vo'}

                    <option value="{$vo.id}" {notempty name="info" }{if condition="  $info['cate_id'] eq $vo['id']"} selected {/if}{/notempty}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">
                (帖子分类)
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                标签
            </label>
            <div class="layui-input-block">
                {volist name='tags' id='vo'}
                <button type="button"  data-id="{$vo.id}" { {if condition=" isset($info)   &&  in_array($vo['id'],$info['tags_array']) eq true "} class="blue" {else/}class="default" {/if} >{$vo['name']}</button>
                {/volist}
            </div>
            <input type="hidden" name="tags"  value="{$info['tags']|default=''}"/>
            {notempty name="$user_id"}<input type="hidden" name="user_id"  value="{$user_id|default=''}"/>   {/notempty}

            <!--<div class="layui-form-mid layui-word-aux">-->
            <!--(文章描述信息/简介)-->
            <!--</div>-->
        </div>



        <div class="layui-form-item">
            <label for="logo" class="layui-form-label">
                <span class="x-red">*</span>多图片
            </label>
            <div id="logo" class="layui-input-block">
                <!--<br/>-->

                {assign name="img_ids" value="$info.img_ids|default=''" /}
                {:widget('file/index', ['name' => 'img_ids', 'value' => $img_ids, 'type' => 'imgs'])}
            </div>
            <!--<div class="layui-form-mid layui-word-aux">-->
            <!--(请上传单张封面图片)-->
            <!--</div>-->
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>帖子内容
            </label>
            <div class="layui-input-block">
                <textarea class="form-control textarea_editor" name="content" maxlength="1000" onchange="this.value=this.value.substring(0, 1000)" onkeydown="this.value=this.value.substring(0, 1000)" onkeyup="this.value=this.value.substring(0, 1000)" placeholder="请输入内容">{$info['content']|default=''}</textarea>
                {:widget('editor/index', array('name'=> 'content','value'=> ''))}
            </div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label">
                审核
            </label>
            <div class="layui-input-block">
                <input type="checkbox" name="state" value="1" lay-skin="switch"  {notempty name='info'}{eq name="info.state" value='1'} checked='checked' {/eq}{/notempty}  lay-text="通过|拒绝">
            </div>
        </div>

<div class="box-footer">
    <input type="hidden" name="type" value="{:input('type')}"/>
    <input type="hidden" name="id" value="{$info['id']|default='0'}"/>

    {include file="layout/edit_btn_group"/}

</div>

</form>
</div>
<script>
    $("body").on('click','.default',function () {

        $(this).removeClass('default');
        $(this).addClass('blue');
        var len= $('.blue').length;
        var str=',';
        for (var i=0; i<len;i++){
            str+=$('.blue').eq(i).attr('data-id')+',';
        }
        $("[name='tags']").val(str);

    })

    $("body").on('click','.blue',function () {
        $(this).removeClass('blue');
        $(this).addClass('default');
        var len= $('.blue').length;
        var str=',';
        for (var i=0; i<len;i++){
            str+=$('.blue').eq(i).attr('data-id')+',';
        }
        $("[name='tags']").val(str);

    })






</script>



<script>
    layui.use('form', function(){
        var form = layui.form;

        form.on('select(aihao)', function(data){
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            if(data.value==1){
                $('#video_url').hide();
                $('#video').show();
            }else{
                $('#video_url').show();
                $('#video').hide();
            }

            form.render(null, 'form');
        });


    });



</script>
